package com.mochat.mochat.controller.userOrder;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mochat.mochat.common.model.RequestPage;
import com.mochat.mochat.common.util.wm.ApiRespUtils;
import com.mochat.mochat.dao.entity.UserOrderEntity;
import com.mochat.mochat.model.ApiRespVO;
import com.mochat.mochat.service.userOrder.IUserOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/userOrder")
public class UserOrderController {

    private final static Logger LOGGER = LoggerFactory.getLogger(UserOrderController.class);

    @Autowired
    private IUserOrderService userOrderService;


    @PostMapping("/createUserOrder")
    public Boolean createUserOrder(@RequestBody UserOrderEntity userOrderEntity){
        boolean save = userOrderService.save(userOrderEntity);
        return save;
    }

    /**
     * 查看订单接口
     * @param contactId
     * @return
     */
    @GetMapping("/getOrderInfoByUserId")
    public ApiRespVO getOrderInfoByUserId(@NotNull(message = "客户 id 不能为空") String contactId,
                                          RequestPage page){
        return ApiRespUtils.getApiRespByPage(userOrderService.getListByUserId(contactId, page));
//        LambdaQueryWrapper<UserOrderEntity> queryWrapper = new LambdaQueryWrapper<>();
//        List<UserOrderEntity> list = IUserOrderService.list(queryWrapper);
//        return list;
    }

}
